using System;

namespace KodeIT.Web
{
    /// <summary>
    /// This class represents the event raised by IIS immediately prior to sending the headers to the client. 
    /// If your HttpFilter should be notified for this event, it should subscribe for the 
    /// <see cref="IFilterEvents.SendResponse"/> event.
    /// </summary>
    /// <remarks>
    /// When handling this event, the filter can inspect, modify, or add headers the client will receive as 
    /// part of the response to the client's original request.
    /// </remarks>
    public class ResponseHeadersEvent : HeadersEvent
    {
        private NativeData<int> _httpStatus;

        internal ResponseHeadersEvent(NativeContext nativeContext, int httpStatus)
            : base(nativeContext)
        {
            _httpStatus = new NativeData<int>(httpStatus);
        }

        /// <summary>
        /// Gets or sets the entire response line.
        /// </summary>
        public string ResponseLine
        {
            get { return Headers[HttpHeader.Status]; }
            set { Headers[HttpHeader.Status] = value; }
        }

        /// <summary>
        /// Gets or sets the http status of the response.
        /// </summary>
        public int HttpStatus
        {
            get { return _httpStatus.Data; }
            set { _httpStatus.Data = value; }
        }
    }
}
